package com.woniuxy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.woniuxy.dto.PageDto;
import com.woniuxy.entity.ProductLine;
import com.woniuxy.service.ProductLineService;
import com.woniuxy.service.ProductLineService;
import com.woniuxy.utils.Result;

@RestController
@RequestMapping("/productLine")
public class ProductLineController {

	@Autowired
	private ProductLineService productLineService;

	@RequestMapping("/find")
	public PageDto<ProductLine> findAllProductLine(Integer page){
		return productLineService.findAllProductLine(page);
	}
	
	@RequestMapping("/add")
	public int addProductLine(ProductLine productLine) {	
		return productLineService.addProductLine(productLine);
	}
	
	@RequestMapping("/findProductLineByStatus")
	public PageDto<ProductLine> findProductLineByStatus(Integer status,Integer page){
		return productLineService.findProductLineByStatus(status, page);
	}
	
	@RequestMapping("/search")
	public PageDto<ProductLine> searchProductLineByLname(String lname,Integer page){
		return productLineService.findProductLineByLname(lname, page);	
	}
	
	@RequestMapping("/delete")
	public Result<Integer> deleteProductLineByLid(Integer lid){
		Result<Integer> result = new Result<>();
		int res = productLineService.deleteProductLineByLid(lid);
		if (res>0) {
			return result.setMessage("删除成功~~");
		}else {
			return result.setMessage("删除失败~~");
		}	
	}
	
	@RequestMapping("/updateSwitch")
	public int updateSwitch(Integer lid, Integer value) {
		return productLineService.updateSwitch(lid, value);
	}
}
